import 'package:flutter/material.dart';
import '../blocs/role_bloc.dart';

class ViewRole {
  Widget getAvatar<T extends RoleBloc>({String playerId, @required T roleBloc}) {
    return Container(
      padding: EdgeInsets.all(10),
      child: StreamBuilder<Map>(
        stream: roleBloc.signStream,
        initialData: roleBloc.signData,
        builder: (BuildContext context, AsyncSnapshot<Map> snapshot) {
          Map userInfo = snapshot.data;
          String uanme = userInfo==null ? '': userInfo['uname'];
          int sex = userInfo==null ? '': userInfo['sex'];
          int asset = userInfo==null ? '': userInfo['asset'];
          return Column(
            children: <Widget>[
              Icon(IconData(snapshot.data['isLandlord'] ? 0xe603 : sex==0?0xe602:0xe640, fontFamily: 'iconfont'), color: Colors.white),
              Container(height: 10),
              LimitedBox(
                maxWidth: 62,
                child: Text(uanme, style: TextStyle(color: Colors.white), maxLines: 1, overflow: TextOverflow.ellipsis)
              ),
              Container(
                alignment: Alignment.center,
                child: Text(asset.toString(), style: TextStyle(color: Colors.white),),
              )
            ]
          );
        }
      )
    );
  }
}